# Maintainer: David Runge <dvzrv@archlinux.org>

_name=django-guardian
pkgname=python-django-guardian
pkgver=2.4.0
pkgrel=4
pkgdesc="Per object permissions for Django"
arch=('any')
url="https://github.com/django-guardian/django-guardian"
license=('BSD' 'MIT')
depends=('python-django' 'python-django-environ')
makedepends=('python-setuptools')
checkdepends=('python-pytest' 'python-pytest-django')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('7e65a27fbb485a047dd02466b7e36daceb4a27b5ff30ec035fa37b7d300e78e43de213606e54d0b1be2e64ae8835a55cef98788ae45ec2446e502fdd312d8ed6')
b2sums=('8eb6ee82ed9eb6098deb8b8c0f1142d3e96f5a2bb5ad5822ddfe8c004a208421e465165fdfec85077ef9b8d03e7222d7d9e132a03e055c0de506b69dfff8f003')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="build:${PYTHONPATH}"
  pytest -v
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
    --optimize=1 \
    --root="${pkgdir}"
  install -vDm 644 {AUTHORS,CHANGES,README.rst} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
